package us.mooresr.geartrack.client.events;

import com.google.gwt.event.shared.GwtEvent;
import com.google.gwt.event.shared.EventHandler;
import us.mooresr.geartrack.shared.model.Person;
import com.google.gwt.event.shared.HasHandlers;

public class PersonChangedEvent extends
		GwtEvent<PersonChangedEvent.PersonChangedHandler> {

	public static Type<PersonChangedHandler> TYPE = new Type<PersonChangedHandler>();
	private Person person;

	public interface PersonChangedHandler extends EventHandler {
		void onPersonChanged(PersonChangedEvent event);
	}

	public PersonChangedEvent(Person person) {
		this.person = person;
	}

	public Person getPerson() {
		return person;
	}

	@Override
	protected void dispatch(PersonChangedHandler handler) {
		handler.onPersonChanged(this);
	}

	@Override
	public Type<PersonChangedHandler> getAssociatedType() {
		return TYPE;
	}

	public static Type<PersonChangedHandler> getType() {
		return TYPE;
	}

	public static void fire(HasHandlers source, Person person) {
		source.fireEvent(new PersonChangedEvent(person));
	}
}
